library(tree)
library(ISLR)
attach(Carseats)
head(Carseats)
High = ifelse(Sales <=8, "No","Yes")
Carseats = data.frame(Carseats,High)
tree.carseats = tree(High ~.-Sales,Carseats)
View(Carseats)
summary(tree.carseats)
plot(tree.carseats)
text(tree.carseats)

library(MASS)
set.seed(1)
train = sample(1:nrow(Boston),nrow(Boston)/2)
tree.boston = tree(medv~.,data=Boston,subset=train)
summary(tree.boston)
plot(tree.boston)
text(tree.boston)
